package com.example.diancai.service;

import com.example.diancai.consts.RedisKeyConst;
import com.example.diancai.dto.CurrentPlayer;
import com.example.diancai.entity.GameUser;
import com.example.diancai.entity.WxUser;
import com.example.diancai.util.AuthUtil;
import com.example.diancai.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class AsyncService {
    @Autowired
    private WxUserService wxUserService;

    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private GameUserService gameUserService;
    @Async
    public void setScore(WxUser wxUser, GameUser gameUser, CurrentPlayer currPlayer,String token) {
        wxUserService.updateById(wxUser);
        redisUtil.setObject(RedisKeyConst.AUTH + token, currPlayer);
        gameUserService.updateById(gameUser);
        log.info("异步结束");
    }
}
